package com.guigu.service.impl.design;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.guigu.mapper.design.DLevelFirstMapper;
import com.guigu.pojo.design.DFile;
import com.guigu.pojo.design.DLevelFirst;
import com.guigu.service.design.DLevelFirstService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Mr.Zhang
 * @since 2024-12-17
 */
@Service
public class DLevelFirstServiceImpl extends ServiceImpl<DLevelFirstMapper, DLevelFirst> implements DLevelFirstService {

    @Autowired
    private DLevelFirstMapper dLevelFirstMapper;

    @Override
    public ArrayList<DLevelFirst> selectAllLevelFirst() {
        ArrayList<DLevelFirst> dLevelFirsts = (ArrayList<DLevelFirst>) dLevelFirstMapper.selectList(null);
        return dLevelFirsts;
    }

    @Override
    public Boolean insertFirst(DLevelFirst first) {
        int rows = dLevelFirstMapper.insert(first);
        return rows > 0;
    }

    @Override
    public DLevelFirst selectDLevelFirstOrderByDescOne() {
        QueryWrapper<DLevelFirst> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByDesc("FIRST_ID");
        queryWrapper.last("limit 1");
        DLevelFirst dLevelFirst = dLevelFirstMapper.selectOne(queryWrapper);
        return dLevelFirst;

    }

}
